package com.bops.dal.product.dao.impl;


import java.util.HashMap;
import java.util.List;

import com.bops.dal.product.dao.Type1DAO;
import com.bops.dal.product.dataobject.TypeOne;
import com.bops.dal.product.queryobject.TypeOneQuery;
import com.yue.commons.db.ibatis.YueBaseSqlMapClientDaoSupport;

public class Type1DAOImpl extends YueBaseSqlMapClientDaoSupport  implements Type1DAO{

	private static final String NAME_SPACE = "TYPE1_PRODUCT.";
	public int countType1(HashMap<String, Object> map) {
		return (Integer) getSqlMapClientTemplate().queryForObject(NAME_SPACE + "count_type1", map);
	}

	public int deleteType1ById(Integer id) {
		int rows = getSqlMapClientTemplate().delete(NAME_SPACE + "delete", id);
		return rows;
	}

	public TypeOne findType1ById(Integer id) {
		return (TypeOne)getSqlMapClientTemplate().queryForObject(NAME_SPACE + "listById", id);
	}
	public TypeOne findIDByName(String name) {
		return (TypeOne) getSqlMapClientTemplate().queryForObject(NAME_SPACE + "idByName", name);
	}
	
	
	public boolean insertType1(TypeOne editType1) {
		getSqlMapClientTemplate().insert(NAME_SPACE + "insert", editType1);
//		ERPCache.clean();
		return false;
	}

	
	public int updateType1(TypeOne editType1) {
		int rows =getSqlMapClientTemplate().update(NAME_SPACE + "update", editType1);
		return rows;
	}

	@SuppressWarnings("unchecked")
	public List<TypeOne> listType1(TypeOneQuery queryType1) {
		 if (queryType1==null)
	        {
			 queryType1 = new TypeOneQuery();
			 queryType1.setPageSize(Integer.MAX_VALUE);
	        }
		return getSqlMapClientTemplate().queryForPagination(NAME_SPACE + "count_type1",
				NAME_SPACE + "list_type1", queryType1);
	}
	@SuppressWarnings("unchecked")
	public List<TypeOne> completeType1(TypeOneQuery queryType1) {
		
		return getSqlMapClientTemplate().queryForList(NAME_SPACE + "complete_Type1", queryType1);
	}

	
	public int checkType1Name(TypeOne editType1 ) {
		return (Integer) getSqlMapClientTemplate().queryForObject(NAME_SPACE + "checkName", editType1);
	}
	
	
}
